#!/usr/bin/env bash
source /etc/profile

if [ -n "$1" ]
then
  do_date=$1
else
  do_date=$(date -d "-1 day" +%F)
fi

sql="
insert overwrite table ads.ads_new_member_cnt
partition (dt='$do_date')
select count(1)
from dws.dws_member_add_day
where dt='$do_date'
"

hive -e "$sql"